<%--
  Created by IntelliJ IDEA.
  User: Starry
  Date: 2024/5/11
  Time: 17:30
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" isELIgnored="false" %>

<%@ taglib prefix="c" uri="jakarta.tags.core" %>
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>编辑用户</title>
    <style>
        body {
            font-family: Arial, sans-serif;
            display: flex;
            justify-content: center;
            align-items: center;
            height: 100vh;
            margin: 0;
            background-color: #f4f4f4;
        }
        form {
            width: 100%;
            max-width: 400px;
            padding: 20px;
            box-shadow: 0 0 10px rgba(0, 0, 0, 0.1);
            border-radius: 5px;
            background-color: #ffffff;
        }
        .form-group {
            display: flex;
            flex-direction: column;
            margin-bottom: 15px;
        }
        label {
            margin-bottom: 5px;
            font-weight: bold;
        }
        input {
            padding: 10px;
            border: 1px solid #ddd;
            border-radius: 4px;
        }
        input[type="submit"] {
            background-color: #4CAF50;
            color: white;
            border: none;
            cursor: pointer;
            margin: auto;
            transition: background-color 0.3s ease;
        }
        input[type="submit"]:hover {
            background-color: #45a049;
        }
        .gender-group {
            display: flex;
            justify-content: space-between;
        }
        .gender-group label {
            margin: 0;
        }
        .gender-group input[type="radio"] {
            margin-right: 5px;
        }
        .center-button {
            display: flex;
            justify-content: center;
        }
    </style>
</head>
<body>

<form action="${pageContext.request.contextPath}/edit" method="post">
    <div class="center-button">
        <h1>编辑用户信息</h1>
        <h5>${msg}</h5>
    </div>
    <input type="hidden" name="id" value="${requestScope.user.id}">
    <div class="form-group">
        <label for="name">姓名:</label>
        <input type="text" id="name" name="username" value="${requestScope.user.username}" required>
    </div>
    <div class="form-group">
        <label for="password">密码:</label>
        <input type="text" id="password" name="password" value="${requestScope.user.password}" required>
    </div>
    <div class="form-group gender-group">
        <%--从requestScope中获取user的gender的值--%>
        <c:set var="gender" value="${requestScope.user.gender}" />

        <label>性别:</label>
        <div>
            <input type="radio" id="male" name="gender" value="男" ${gender eq '男' ? 'checked' : ''}>
            <label for="male">男</label>
        </div>
        <div>
            <input type="radio" id="female" name="gender" value="女" ${gender eq '女' ? 'checked' : ''}>
            <label for="female">女</label>
        </div>
    </div>
    <div class="form-group">
        <label for="phone">电话:</label>
        <input type="tel" id="phone" name="phone" value="${requestScope.user.phone}" pattern="[0-9]{3}[0-9]{4}[0-9]{4}" required >
    </div>
    <div class="center-button">
        <input type="submit" value="保存">
    </div>
</form>
</body>
</html>